package com.leonzx.base.service.mail;

import com.leonzx.base.dao.email.UserMailDAO;
import com.leonzx.base.entity.email.UserMail;
import com.leonzx.base.service.BaseService;
import com.leonzx.base.utils.UUIDUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @Author:chen
 * @Description:
 * @Date: 2018-07-06 09:35
 */
@Service
public class UserMailService extends BaseService {

    @Autowired
    private UserMailDAO userMailDAO;


    public UserMail findUserMailByUserId(String userId) {
        return userMailDAO.findByUserId(userId);
    }

    public void saveUserMail(UserMail userMail) {
        userMailDAO.del(userMail.getUserId());
        userMail.setId(UUIDUtils.getUUID());
        userMail.setUserId(userMail.getUserId());
        userMail.setCreateTime(new Date());
        userMail.setCreateUserId(userMail.getUserId());
        userMailDAO.insert(userMail);
    }

    public List<UserMail> findUserMailByMailIsNotNull(String userId, String name, String currentUserId){
        return userMailDAO.findUserMailByMailIsNotNull(userId, name, currentUserId);
    }
}
